package demo9;

public class Test {
    //private static boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("线程正在工作！");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程执行完毕！");
        });
        t.start();
        Thread.sleep(3000);
        //isQuit=true;
        //System.out.println("标志位被设置为true!");
        t.interrupt();
    }
}
